package main

import (
	"fmt"
	"io"
	"net/http"
	"nh-poc/pkg/middleware"
	"time"
)

func main() {
	accessKey := "ak"
	secretKey := "sk"
	url := "https://localhost:9093/test"

	// 生成签名
	timestamp := time.Now().Unix()
	signature := middleware.GenerateSignature("GET", "/test", fmt.Sprintf("%d", timestamp), secretKey)

	// 创建请求
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("X-Access-Key", accessKey)
	req.Header.Add("X-Signature", signature)
	req.Header.Add("X-Timestamp", fmt.Sprintf("%d", timestamp))

	// 发送请求
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println("Response Status:", resp.Status)
	fmt.Println("Response Body:", string(body))
}
